package top.superflow.utils

object AutoProxy {

  def copyFields[R <: T, T](newObj: R, copyObj : Any, clz : Class[T]): R={

    for(field <- clz.getDeclaredFields){
      val originalAccessible = field.isAccessible
      field.setAccessible(true)
      val copyValue = field.get(copyObj)
      field.set(newObj.asInstanceOf[T], copyValue)
      field.setAccessible(originalAccessible)
    }

    newObj
  }

}
